package main;


import main.canvas.DisplayFrame;
import main.canvas.RiverCanvas;
import main.canvas.RiverGrid;
import main.canvas.components.ImageComponent;

import java.awt.*;

public class RiverApp2 {

    public static void main(String[] args) {
        GraphicsDevice device = getDevice();
        DisplayMode[] displayModes = device.getDisplayModes();
        DisplayMode displayMode = displayModes[displayModes.length - 1];
        RiverGrid root = new RiverGrid(12, 12, displayMode.getHeight(), displayMode.getHeight());
        root.setX((displayMode.getWidth() - root.getWidth()) / 2);
        for (int column = 0; column < root.getColumns(); column++) {
            root.add(column, 0, new ImageComponent("img/grass.jpg"));
            root.add(column, 11, new ImageComponent("img/grass.jpg"));
        }
        for (int column = 0; column < root.getColumns(); column++) {
            for (int row = 1; row < root.getRows() - 1; row++) {
                root.add(column, row, new ImageComponent("img/water.gif"));
            }
        }

        DisplayFrame frame = new DisplayFrame(new RiverCanvas(root), device);
        device.setFullScreenWindow(frame);
        frame.go();
    }


    private static GraphicsDevice getDevice() {
        return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    }
}
